The present disclosure relates to processing in a computer system; more specifically the present disclosure relates to a method and system for dynamic linkage.
Computer systems typically include a combination of hardware (e.g., semiconductors, circuit boards, etc.) and software (e.g., computer programs). As advances in semiconductor processing and computer architecture push the performance of the computer hardware higher, more sophisticated computer software has evolved to take advantage of the higher performance of the hardware, resulting in computer systems today that are much more powerful than just a few years ago.
Computer systems typically include operating system software that controls the basic function of the computer, and one or more software application programs that run under the control of the operating system to perform desired tasks. For example, a typical IBM Personal Computer may run an operating system, and under the control of the operating system, a user may execute an application program, such as a word processor. As the capabilities of computers have increased, the application programs designed for high performance computer systems have become extremely powerful.
Standard libraries consist of commonly used functions that are not provided directly in the programming language. Nearly all programs use various functions from standard libraries. Functions from these standard libraries can be incorporated into executables in one of two ways either, statically or dynamically. In the static method, the functions are loaded into memory as part of the executable program. In the dynamic method, the functions are part of a separate executable that is loaded into memory at the same time the program is loaded or when they are actually called. One drawback of static linkage is that it wastes space. For example, if there 200 executable programs, there will be 200 copies of the standard library routines because a copy is included in each of the programs. However in dynamic linkage, all the programs that use it share one copy of the standard library. Each program that uses a standard library contains a reference to it. When the program is loaded into memory to run, the loader uses the reference information to find the standard library and loads it as well. While dynamic linkage saves space, it provides a slower start up time than statically linked programs because programs usually reference a number of different libraries which all must be processed before the program can run.
Currently in the LINUX environment, dynamic linkage is done on a per-process basis. Each process calls a main application, which in turn can call functions or reference data in other libraries (shared objects). The main application is executed by a process and is loaded to a fixed virtual address. All run-time libraries needed by the application are loaded to variable addresses within the process' virtual address space. These other libraries (shared objects) may need to be read into memory from file or may already be in memory. In either case, once in memory, the shared objects need to be mapped to the process' virtual address space. All absolute addresses within the shared object reside in a “data segment” or writable segment, which makes use of the “copy-on-write” function to create a unique copy in memory for the current process. These absolute addresses need to be relocated to the new virtual address for this process and this needs to occur for all shared objects needed by the application (and recursively for all shared objects needed by the shared objects). In addition, the references to the shared objects need to be resolved within the called application.
Process creation overhead has been reduced through the use of a process known as “lazy binding”. Lazy binding enables code to be executed without full resolving all external function calls. Instead, at runtime, a function call can result in a call directed to the operating system to perform relocation as necessary. If a program contains many calls to functions that are not used during a typical execution of the program, then lazy binding can save some unnecessary lookups. If anything, this attempt to reduce process creation overhead illustrates the fact that process creation overhead using this model is high.
Therefore what is needed is a method of dynamic linkage that reduces process creation overhead and therefore has a faster start up time than existing dynamic linkage methods.